// GameTime.cs
//

using System;
using System.Collections.Generic;

namespace Moonbeam.Core
{
    public class GameTime
    {
        int startMiliseconds;
        int targetTimeMilliseconds;

        public int TotalElapsedMilliseconds;
        public int ElapsedMiliseconds;
        public bool IsRunningSlowly;

        public GameTime(int _targetTimeMilliseconds)
        {
            startMiliseconds = Date.Now.GetTime();
            targetTimeMilliseconds = _targetTimeMilliseconds;
        }

        public void Update()
        {
            int nowMiliseconds = Date.Now.GetTime();

            //time passed since last update
            ElapsedMiliseconds = (nowMiliseconds - TotalElapsedMilliseconds) - startMiliseconds;

            //time elapsed since object creation
            TotalElapsedMilliseconds = nowMiliseconds - startMiliseconds;

            if (ElapsedMiliseconds > targetTimeMilliseconds)
            {
                IsRunningSlowly = true;
            }
            else
            {
                IsRunningSlowly = false;
            }
        }
    }
}
